<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
    <script src="./velocity.js"></script><!-- 引入velocity.js库 -->
</head>
<body>
    <div id="app">             <!-- js入场动画钩子 -->
        <transition name="fade" @before-enter="handleBeforEnter" @enter="handleEnter" @after-enter="handleAfterEnter"><!-- transition包裹的内容会有动画过渡效果 -->
            <div v-if="show">hello world</div>
        </transition>
        <button @click="handleClick">切换</button>
    </div>
    <script>
        var vm=new Vue({
            el:'#app',
            data:{
                show:true
            },
            methods:{
                handleClick:function(){
                    this.show=!this.show;
                },
                handleBeforEnter:function(el){//el指向transition中的div标签
                    /* el.style.color='red' */
                    el.style.opacity=0;
                },
                handleEnter:function(el,done){
                    /* setTimeout(() => {
                        el.style.color='green'
                    }, 2000);
                    setTimeout(() => {
                        done()
                    }, 4000); */
                    Velocity(el,{opacity:1},{duration:3000,complete:done})//调用Velocity.js库
                },
                handleAfterEnter:function(el){
                   /*  el.style.color='black' */
                   console.log("动画执行完毕");
                }

            }

        })
    </script>
</body>
</html>